package java51.homew0614;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.net.Socket;
import java.util.Scanner;

public class ClientWeather {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Socket s = null;
		try {
			s = new Socket("192.168.1.98", 2333);
			InputStream in = s.getInputStream();
			OutputStream out = s.getOutputStream();
			BufferedReader br = new BufferedReader(new InputStreamReader(in));
			PrintWriter pw = new PrintWriter(out);
			while (true) {
				System.out.println("请输入你的选择：1.查询天气  2.查询pm2.5 3.查询空气湿度  4.退出");
				String s1 = sc.nextLine();
				pw.println(s1);
				pw.flush();
				if (s1.equals("4"))
					break;
				String s2 = br.readLine();
				System.out.println(s2);
			}
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			try {
				s.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
	}

}
